﻿using System;
using System.Collections.Generic;
using Character;
using RootMotion.FinalIK;
using UnityEngine;

// Token: 0x02000157 RID: 343
public class Male : Human
{
	// Token: 0x1700011B RID: 283
	// (get) Token: 0x060008C4 RID: 2244 RVA: 0x00033288 File Offset: 0x00031488
	public MALE_SHOW MaleShow
	{
		get
		{
			return this.maleShow;
		}
	}

	// Token: 0x1700011C RID: 284
	// (get) Token: 0x060008C5 RID: 2245 RVA: 0x00033290 File Offset: 0x00031490
	// (set) Token: 0x060008C6 RID: 2246 RVA: 0x00033298 File Offset: 0x00031498
	public MALE_ID MaleID
	{
		get
		{
			return this.maleID;
		}
		set
		{
			this.SetMaleID(value);
		}
	}

	// Token: 0x1700011D RID: 285
	// (get) Token: 0x060008C7 RID: 2247 RVA: 0x000332A4 File Offset: 0x000314A4
	public bool WearShoes
	{
		get
		{
			return this.wearShoes;
		}
	}

	// Token: 0x1700011E RID: 286
	// (get) Token: 0x060008C8 RID: 2248 RVA: 0x000332AC File Offset: 0x000314AC
	// (set) Token: 0x060008C9 RID: 2249 RVA: 0x000332B4 File Offset: 0x000314B4
	public bool visibleSon { get; protected set; }

	// Token: 0x060008CA RID: 2250 RVA: 0x000332C0 File Offset: 0x000314C0
	private void Awake()
	{
		base.sex = SEX.MALE;
		base.visibleAll = true;
		this.visibleSon = true;
		Transform parent = Transform_Utility.FindTransform(base.transform, "cm_J_Head_s");
		base.customParam = new CustomParameter(SEX.MALE);
		base.SetDefParam();
		base.head = new Head(this, parent);
		base.body = new Body(this, null, null);
		base.hairs = new Hairs(this, null);
		base.wears = new Wears(base.sex, base.customParam.wear, base.transform, this);
		base.accessories = new Accessories(base.sex, base.transform);
		this.silhouetteRend = Transform_Utility.FindComponent<SkinnedMeshRenderer>(base.gameObject, "cm_body_silhouette");
		AttachBoneWeight.Attach(base.body.AnimatedBoneRoot.gameObject, this.silhouetteRend.gameObject, true);
		this.silhouetteRend.enabled = false;
		this.tinRoot = Transform_Utility.FindTransform(base.transform, "N_dan").gameObject;
		Transform transform = Transform_Utility.FindTransform(base.transform, "cm_J_dan101_00");
		Transform tinTip = Transform_Utility.FindTransform(base.transform, "cm_J_dan109_00");
		Transform mouthTrans = Transform_Utility.FindTransform(base.transform, "N_Mouth");
		base.ik = new IK_Control(base.GetComponentInChildren<FullBodyBipedIK>(), transform, tinTip, mouthTrans);
		this.SetTongueType(TONGUE_TYPE.FACE);
		this.neckLook = base.transform.GetComponentInChildren<LookAtRotator>();
		this.maleID = MALE_ID.NUM;
	}

	// Token: 0x060008CB RID: 2251 RVA: 0x0003342C File Offset: 0x0003162C
	public void SetMaleID(MALE_ID maleID)
	{
		this.maleID = maleID;
		this.maleShow = GlobalData.maleShows[(int)maleID];
	}

	// Token: 0x060008CC RID: 2252 RVA: 0x00033444 File Offset: 0x00031644
	private void Start()
	{
	}

	// Token: 0x060008CD RID: 2253 RVA: 0x00033448 File Offset: 0x00031648
	protected override void Update()
	{
		base.Update();
	}

	// Token: 0x060008CE RID: 2254 RVA: 0x00033450 File Offset: 0x00031650
	protected override float GetVolume()
	{
		if (this.maleID == MALE_ID.HERO)
		{
			return ConfigData.VolumeVoice_Hero();
		}
		if (this.maleID == MALE_ID.KOUICHI)
		{
			return ConfigData.VolumeVoice_Kouichi();
		}
		if (this.maleID >= MALE_ID.MOB_A && this.maleID <= MALE_ID.MOB_C)
		{
			return ConfigData.VolumeVoice_Mob();
		}
		return 0f;
	}

	// Token: 0x060008CF RID: 2255 RVA: 0x000334A4 File Offset: 0x000316A4
	protected override float GetVoicePitch()
	{
		if (this.maleID == MALE_ID.HERO)
		{
			return ConfigData.PitchVoice_Hero();
		}
		if (this.maleID == MALE_ID.KOUICHI)
		{
			return ConfigData.PitchVoice_Kouichi();
		}
		return 1f;
	}

	// Token: 0x060008D0 RID: 2256 RVA: 0x000334D0 File Offset: 0x000316D0
	public override void Save(string file)
	{
		base.StartCoroutine(base.ToCharaPNG(file, "【PlayHome_Male】"));
	}

	// Token: 0x060008D1 RID: 2257 RVA: 0x000334E8 File Offset: 0x000316E8
	public override void Save(string file, Texture2D tex)
	{
		base.ToCharaPNG(file, "【PlayHome_Male】", tex);
	}

	// Token: 0x060008D2 RID: 2258 RVA: 0x000334F8 File Offset: 0x000316F8
	public override void SaveCoordinate(string file)
	{
		base.StartCoroutine(file, "【PlayHome_MaleCoordinate】");
	}

	// Token: 0x060008D3 RID: 2259 RVA: 0x00033508 File Offset: 0x00031708
	public override void SaveCoordinate(string file, Texture2D tex)
	{
		base.ToCoordinatePNG(file, "【PlayHome_MaleCoordinate】", tex);
	}

	// Token: 0x060008D4 RID: 2260 RVA: 0x00033518 File Offset: 0x00031718
	public override LOAD_MSG Load(string file, int filter = -1)
	{
		return base.Load(file, false, true, filter);
	}

	// Token: 0x060008D5 RID: 2261 RVA: 0x00033524 File Offset: 0x00031724
	public override LOAD_MSG Load(TextAsset text, int filter = -1)
	{
		return base.Load(text, false, true, filter);
	}

	// Token: 0x060008D6 RID: 2262 RVA: 0x00033530 File Offset: 0x00031730
	public override LOAD_MSG LoadCoordinate(string file, int filter = -1)
	{
		return base.LoadCoordinate(file, false, true, filter);
	}

	// Token: 0x060008D7 RID: 2263 RVA: 0x0003353C File Offset: 0x0003173C
	public override LOAD_MSG LoadCoordinate(TextAsset text, int filter = -1)
	{
		return base.LoadCoordinate(text, false, true, filter);
	}

	// Token: 0x060008D8 RID: 2264 RVA: 0x00033548 File Offset: 0x00031748
	public override void Apply()
	{
		if (base.charReference == null)
		{
			base.charReference = base.gameObject.GetOrAddComponent<CharReference>();
		}
		base.body.Load(base.gameObject, base.customParam.body);
		base.charReference.CreateReferenceInfo(1UL, 0, base.gameObject);
		base.charReference.CreateReferenceInfo(2UL, 0, base.gameObject);
		base.charReference.CreateReferenceInfo(8UL, 0, base.gameObject);
		base.head.Load(base.customParam.head);
		base.charReference.CreateReferenceInfo(3UL, 0, base.head.Obj);
		Transform hairsParent = Transform_Utility.FindTransform(base.head.Obj.transform, "cm_J_FaceUp_ty");
		base.hairs.SetHairsParent(hairsParent);
		base.hairs.Load(base.customParam.hair);
		for (WEAR_TYPE wear_TYPE = WEAR_TYPE.TOP; wear_TYPE < WEAR_TYPE.NUM; wear_TYPE++)
		{
			base.wears.WearInstantiate(wear_TYPE, base.body.SkinMaterial, base.body.CustomHighlightMat_Skin);
		}
		base.wears.CheckShow(true);
		for (int i = 0; i < 10; i++)
		{
			base.accessories.AccessoryInstantiate(base.customParam.acce, i, false, null);
		}
		base.lipSync = base.GetComponentInChildren<AnimeLipSync>();
		base.blink = base.GetComponentInChildren<AnimeParamBlink>();
		this.eyeLook = base.head.Obj.GetComponentInChildren<LookAtRotator>();
		base.HeadPosTrans = Transform_Utility.FindTransform(base.body.AnimatedBoneRoot, "aim");
		base.BrestPosTrans = Transform_Utility.FindTransform(base.body.AnimatedBoneRoot, "cm_J_Spine03");
		base.CrotchTrans = Transform_Utility.FindTransform(base.body.AnimatedBoneRoot, "cm_J_Kokan");
		Resources.UnloadUnusedAssets();
		this.ChangeMaleShow(this.maleShow);
		this.SetupExpression();
		if (base.ik != null)
		{
			Transform mouthTrans = Transform_Utility.FindTransform(base.body.AnimatedBoneRoot, "N_Mouth");
			base.ik.SetMouthTrans(mouthTrans);
		}
	}

	// Token: 0x060008D9 RID: 2265 RVA: 0x0003376C File Offset: 0x0003196C
	public override void ApplyCoordinate()
	{
		for (WEAR_TYPE wear_TYPE = WEAR_TYPE.TOP; wear_TYPE < WEAR_TYPE.NUM; wear_TYPE++)
		{
			base.wears.WearInstantiate(wear_TYPE, base.body.SkinMaterial, base.body.CustomHighlightMat_Skin);
		}
		base.wears.CheckShow(true);
		for (int i = 0; i < 10; i++)
		{
			base.accessories.AccessoryInstantiate(base.customParam.acce, i, false, null);
		}
		Resources.UnloadUnusedAssets();
		this.ChangeMaleShow(this.maleShow);
	}

	// Token: 0x060008DA RID: 2266 RVA: 0x000337F8 File Offset: 0x000319F8
	public override void ApplyHair()
	{
		Transform hairsParent = Transform_Utility.FindTransform(base.head.Obj.transform, "cm_J_FaceUp_ty");
		base.hairs.SetHairsParent(hairsParent);
		base.hairs.Load(base.customParam.hair);
		this.ChangeMaleShow(this.maleShow);
	}

	// Token: 0x060008DB RID: 2267 RVA: 0x00033850 File Offset: 0x00031A50
	public override void ChangeHead()
	{
		base.ChangeHead("cm_J_FaceUp_ty");
		this.ChangeMaleShow(this.maleShow);
		this.SetupExpression();
		if (base.ik != null)
		{
			Transform mouthTrans = Transform_Utility.FindTransform(base.body.AnimatedBoneRoot, "N_Mouth");
			base.ik.SetMouthTrans(mouthTrans);
		}
	}

	// Token: 0x060008DC RID: 2268 RVA: 0x000338A8 File Offset: 0x00031AA8
	public void ChangeMaleShow(MALE_SHOW show)
	{
		this.maleShow = show;
		if (show == MALE_SHOW.CLOTHING)
		{
			base.wears.ChangeShow(WEAR_SHOW_TYPE.TOPUPPER, WEAR_SHOW.ALL);
			base.wears.ChangeShow(WEAR_SHOW_TYPE.TOPLOWER, WEAR_SHOW.ALL);
			base.wears.ChangeShow(WEAR_SHOW_TYPE.SHOES, WEAR_SHOW.ALL);
			this.CheckShow();
		}
		else if (show == MALE_SHOW.NUDE)
		{
			base.wears.ChangeShow(WEAR_SHOW_TYPE.TOPUPPER, WEAR_SHOW.HIDE);
			base.wears.ChangeShow(WEAR_SHOW_TYPE.TOPLOWER, WEAR_SHOW.HIDE);
			base.wears.ChangeShow(WEAR_SHOW_TYPE.SHOES, WEAR_SHOW.HIDE);
			this.CheckShow();
		}
		else if (show == MALE_SHOW.ONECOLOR)
		{
			base.wears.ChangeShow(WEAR_SHOW_TYPE.TOPUPPER, WEAR_SHOW.HIDE);
			base.wears.ChangeShow(WEAR_SHOW_TYPE.TOPLOWER, WEAR_SHOW.HIDE);
			base.wears.ChangeShow(WEAR_SHOW_TYPE.SHOES, WEAR_SHOW.HIDE);
			this.CheckShow();
		}
		else if (show == MALE_SHOW.TIN)
		{
			base.wears.ChangeShow(WEAR_SHOW_TYPE.TOPUPPER, WEAR_SHOW.HIDE);
			base.wears.ChangeShow(WEAR_SHOW_TYPE.TOPLOWER, WEAR_SHOW.HIDE);
			base.wears.ChangeShow(WEAR_SHOW_TYPE.SHOES, WEAR_SHOW.HIDE);
			this.CheckShow();
		}
		else if (show == MALE_SHOW.HIDE)
		{
			base.wears.ChangeShow(WEAR_SHOW_TYPE.TOPUPPER, WEAR_SHOW.HIDE);
			base.wears.ChangeShow(WEAR_SHOW_TYPE.TOPLOWER, WEAR_SHOW.HIDE);
			base.wears.ChangeShow(WEAR_SHOW_TYPE.SHOES, WEAR_SHOW.HIDE);
			this.CheckShow();
		}
	}

	// Token: 0x060008DD RID: 2269 RVA: 0x000339D8 File Offset: 0x00031BD8
	public override void CheckShow()
	{
		bool flag = this.maleShow == MALE_SHOW.CLOTHING || this.maleShow == MALE_SHOW.NUDE;
		base.head.ChangeShow(flag);
		base.hairs.ChangeShow(flag);
		base.wears.CheckShow(flag);
		base.accessories.ChangeAllShow(flag);
		this.silhouetteRend.enabled = (this.maleShow == MALE_SHOW.ONECOLOR);
		if (flag)
		{
			this.SetTongueType(base.TongueType);
		}
		else
		{
			base.body.SetShowTongue(false);
			base.head.SetShowTongue(false);
		}
	}

	// Token: 0x060008DE RID: 2270 RVA: 0x00033A70 File Offset: 0x00031C70
	public void SetupExpression()
	{
		this.eyeLook = base.head.Obj.GetComponentInChildren<LookAtRotator>();
		this.eyeLook.Change(this.eyeLookType, this.eyeLookTarget, this.eyeLookForce);
		base.ExpressionPlay(0, this.eyeState, 0f);
		base.ExpressionPlay(1, this.mouthState, 0f);
		base.OpenEye(this.eyeOpen);
		base.OpenMouth(this.mouthOpen);
	}

	// Token: 0x060008DF RID: 2271 RVA: 0x00033AEC File Offset: 0x00031CEC
	public void Ejaculation(bool many)
	{
		this.ejaculator.emitTime = ((!many) ? this.ejaculationNormalTime : this.ejaculationManylTime);
		this.ejaculator.emitNum = ((!many) ? this.ejaculationNormalNum : this.ejaculationManylNum);
		this.ejaculator.StartEmit();
	}

	// Token: 0x060008E0 RID: 2272 RVA: 0x00033B48 File Offset: 0x00031D48
	public void SetShowTinWithWear(bool flag)
	{
		this.tinWithWear = flag;
		this.CheckShow();
	}

	// Token: 0x060008E1 RID: 2273 RVA: 0x00033B58 File Offset: 0x00031D58
	public void SetWearShoes(bool flag)
	{
		this.wearShoes = flag;
		this.CheckShow();
	}

	// Token: 0x060008E2 RID: 2274 RVA: 0x00033B68 File Offset: 0x00031D68
	public override void Foot(MapData.FOOT foot)
	{
		this.SetWearShoes(foot == MapData.FOOT.SHOES);
	}

	// Token: 0x060008E3 RID: 2275 RVA: 0x00033B74 File Offset: 0x00031D74
	public static string MaleName(MALE_ID maleID)
	{
		string[] array = new string[]
		{
			"主人公",
			"広一",
			"モブ男A",
			"モブ男B",
			"モブ男C"
		};
		string result = "- UNKNOWN -";
		if (maleID >= MALE_ID.HERO && maleID < MALE_ID.NUM)
		{
			result = array[(int)maleID];
		}
		return result;
	}

	// Token: 0x060008E4 RID: 2276 RVA: 0x00033BCC File Offset: 0x00031DCC
	public override void SetVisibleAll(bool _visible)
	{
		base.visibleAll = _visible;
		this.ChangeMaleShow((MALE_SHOW)((!_visible) ? 2 : 0));
		if (_visible)
		{
			this.SetVisibleSon(this.visibleSon);
		}
		else
		{
			bool visibleSon = this.visibleSon;
			this.SetVisibleSon(false);
			this.visibleSon = visibleSon;
		}
	}

	// Token: 0x060008E5 RID: 2277 RVA: 0x00033C20 File Offset: 0x00031E20
	public void SetVisibleSon(bool _visible)
	{
		this.visibleSon = _visible;
		this.tinRoot.SetActive(base.visibleAll && _visible);
	}

	// Token: 0x060008E6 RID: 2278 RVA: 0x00033C3C File Offset: 0x00031E3C
	public void SetSimpleDraw(bool _draw)
	{
		this.simpleDraw = _draw;
		this.ChangeMaleShow((MALE_SHOW)((!_draw) ? 0 : 1));
	}

	// Token: 0x060008E7 RID: 2279 RVA: 0x00033C5C File Offset: 0x00031E5C
	public void SetSimpleColor(Color _color)
	{
		this.silhouetteRend.material.color = _color;
	}

	// Token: 0x060008E8 RID: 2280 RVA: 0x00033C70 File Offset: 0x00031E70
	public void SetWearsShow(WEAR_SHOW_TYPE _type, WEAR_SHOW _show)
	{
		this.dicWerasShow[_type] = _show;
		if (this.simpleDraw || !base.visibleAll)
		{
			return;
		}
		base.wears.ChangeShow(_type, _show);
	}

	// Token: 0x060008E9 RID: 2281 RVA: 0x00033CA4 File Offset: 0x00031EA4
	public void SetAccessoryShow(int _id, bool _show)
	{
		this.dicAccessoryShow[_id] = _show;
		if (this.simpleDraw || !base.visibleAll)
		{
			return;
		}
		base.accessories.SetShow(_id, _show);
	}

	// Token: 0x060008EA RID: 2282 RVA: 0x00033CD8 File Offset: 0x00031ED8
	private void ChangeMaleShow(byte _type)
	{
		if (_type == 0 && this.simpleDraw)
		{
			_type = 1;
		}
		if (_type == 1 && !base.visibleAll)
		{
			_type = 2;
		}
		if (_type != 0)
		{
			if (_type != 1)
			{
				if (_type == 2)
				{
					this.maleShow = MALE_SHOW.HIDE;
					base.wears.ChangeShow(WEAR_SHOW_TYPE.TOPUPPER, WEAR_SHOW.HIDE);
					base.wears.ChangeShow(WEAR_SHOW_TYPE.TOPLOWER, WEAR_SHOW.HIDE);
					base.wears.ChangeShow(WEAR_SHOW_TYPE.SHOES, WEAR_SHOW.HIDE);
					this.CheckShow();
					base.body.ShowUnderHair(false);
				}
			}
			else
			{
				this.maleShow = MALE_SHOW.ONECOLOR;
				base.wears.ChangeShow(WEAR_SHOW_TYPE.TOPUPPER, WEAR_SHOW.HIDE);
				base.wears.ChangeShow(WEAR_SHOW_TYPE.TOPLOWER, WEAR_SHOW.HIDE);
				base.wears.ChangeShow(WEAR_SHOW_TYPE.SHOES, WEAR_SHOW.HIDE);
				this.CheckShow();
			}
		}
		else
		{
			this.maleShow = MALE_SHOW.CLOTHING;
			WEAR_SHOW wear_SHOW = WEAR_SHOW.ALL;
			base.wears.ChangeShow(WEAR_SHOW_TYPE.TOPUPPER, (!this.dicWerasShow.TryGetValue(WEAR_SHOW_TYPE.TOPUPPER, out wear_SHOW)) ? WEAR_SHOW.ALL : wear_SHOW);
			base.wears.ChangeShow(WEAR_SHOW_TYPE.TOPLOWER, (!this.dicWerasShow.TryGetValue(WEAR_SHOW_TYPE.TOPLOWER, out wear_SHOW)) ? WEAR_SHOW.ALL : wear_SHOW);
			base.wears.ChangeShow(WEAR_SHOW_TYPE.SHOES, (!this.dicWerasShow.TryGetValue(WEAR_SHOW_TYPE.SHOES, out wear_SHOW)) ? WEAR_SHOW.ALL : wear_SHOW);
			this.CheckShow();
			foreach (KeyValuePair<int, bool> keyValuePair in this.dicAccessoryShow)
			{
				base.accessories.SetShow(keyValuePair.Key, keyValuePair.Value);
			}
			base.body.ShowUnderHair(true);
		}
	}

	// Token: 0x04000863 RID: 2147
	private const string HeadParentName = "cm_J_Head_s";

	// Token: 0x04000864 RID: 2148
	private const string HairParentName = "cm_J_FaceUp_ty";

	// Token: 0x04000865 RID: 2149
	private const string SilhouetteName = "cm_body_silhouette";

	// Token: 0x04000866 RID: 2150
	private const string TinRootName = "N_dan";

	// Token: 0x04000867 RID: 2151
	private const string IK_Tin_Root = "cm_J_dan101_00";

	// Token: 0x04000868 RID: 2152
	private const string IK_Tin_Tip = "cm_J_dan109_00";

	// Token: 0x04000869 RID: 2153
	private const string IK_Mouth = "N_Mouth";

	// Token: 0x0400086A RID: 2154
	private SkinnedMeshRenderer silhouetteRend;

	// Token: 0x0400086B RID: 2155
	private MALE_SHOW maleShow;

	// Token: 0x0400086C RID: 2156
	private MALE_ID maleID = MALE_ID.NUM;

	// Token: 0x0400086D RID: 2157
	private GameObject tinRoot;

	// Token: 0x0400086E RID: 2158
	[SerializeField]
	private int ejaculationNormalNum = 3;

	// Token: 0x0400086F RID: 2159
	[SerializeField]
	private int ejaculationManylNum = 15;

	// Token: 0x04000870 RID: 2160
	[SerializeField]
	private float ejaculationNormalTime = 0.5f;

	// Token: 0x04000871 RID: 2161
	[SerializeField]
	private float ejaculationManylTime = 2.5f;

	// Token: 0x04000872 RID: 2162
	[SerializeField]
	private RigidEmitter ejaculator;

	// Token: 0x04000873 RID: 2163
	private bool tinWithWear = true;

	// Token: 0x04000874 RID: 2164
	private bool wearShoes = true;

	// Token: 0x04000875 RID: 2165
	private Dictionary<WEAR_SHOW_TYPE, WEAR_SHOW> dicWerasShow = new Dictionary<WEAR_SHOW_TYPE, WEAR_SHOW>();

	// Token: 0x04000876 RID: 2166
	private Dictionary<int, bool> dicAccessoryShow = new Dictionary<int, bool>();

	// Token: 0x04000877 RID: 2167
	private bool simpleDraw;
}
